﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KingSite.SyncDB.Core.Entity;
using KingSite.SyncDB.Core.Repository;

namespace KingSite.SyncDBManager {
    public partial class SyncJobDetailView : Form {
        SyncRepository sr = new SyncRepository();
        int SyncId;
        public SyncJobInfo job = new SyncJobInfo();
        public SyncJobDetailView() {
            InitializeComponent();
        }

        private void SyncJobDetailView_Load(object sender, EventArgs e) {
            Init();
        }

        private void Init() {
            IList<SyncEntity> list = sr.GetSyncEntityList(job);
            dataGridView1.DataSource = list;
        }

        private void DelCurrentColumnJobToolStripMenuItem_Click(object sender, EventArgs e) {
            DeleteSync(SyncId);
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) {
            if (dataGridView1.SelectedCells.Count != 0) {
                //得到选中行某列的值
                SyncId = Convert.ToInt32(dataGridView1.CurrentRow.Cells["SyncId"].Value);
            }
        }

        public void DeleteSync(int syncId) {
            sr.Delete(syncId);
            Init();
        }         
    }
}
